public class ExempleThread7 {

    private static final int NBTHREADS = 20;
    private static final int ITERATIONS = 1000;

    public static void  main(String args[]) {
        Thread threadsD[] = new Thread[NBTHREADS];
        Thread threadsR[] = new Thread[NBTHREADS];

        Compte compte = new CompteVersion2(0);


        for (int j = 0; j < NBTHREADS; j++) {
            threadsD[j]=new Thread(new ThreadDeposer(j, compte, ITERATIONS));
            threadsD[j].setName(j+"");
            threadsR[j]=new Thread(new ThreadRetirer(j+NBTHREADS, compte, ITERATIONS));
            threadsR[j].setName((j+NBTHREADS)+"");
        }

        for (int j = 0; j < NBTHREADS; j++) {
            threadsR[j].start();
        }

        for (int j = 0; j < NBTHREADS; j++) {
            threadsD[j].start();
        }


        try {
            for (int j = 0; j < NBTHREADS; j++) {
                threadsD[j].join();
                threadsR[j].join();
            }
        } catch (Exception e ) {
        }

        System.out.print(compte.consulter() +" ");
        System.exit(0);

    }

}
